﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_UPDMS_MNY_BATCH_Mny4011b_Get_Account_On_Monthly_Close')
	BEGIN
		DROP Procedure usp_UPDMS_MNY_BATCH_Mny4011b_Get_Account_On_Monthly_Close
	END
GO

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
/******************************************************************************
**	Name : usp_UPDMS_MNY_BATCH_Mny4011b_Get_Account_On_Monthly_Close
**	Desc : 월마감 대상 저축계정 목록
**	Test Exec Query : Exec usp_UPDMS_MNY_BATCH_Mny4011b_Get_Account_On_Monthly_Close 'ko'
**	Called by : Mny_Dac_UPDMS_MNY_REPORT_Mny4011b.cs
**	Program ID : Mny4011b
**	Auth : 송시명
**	Date : 2010-10-11
*******************************************************************************
**	Change History
*******************************************************************************
**	Date:		Author:		Description:
**	--------	--------	---------------------------------------
**	
*******************************************************************************/
CREATE PROC [dbo].[usp_UPDMS_MNY_BATCH_Mny4011b_Get_Account_On_Monthly_Close]
@ls_lang_set nvarchar(2)
AS
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON

SELECT Account,
       dbo.ufn_UPDMS_Get_Code_Name(Account, 'MNY', @ls_lang_set) AS Account_Nm,
       Total_Amount
  FROM (
       SELECT Account,
              SUM(ISNULL(Amount, 0)) AS Total_Amount
         FROM UPDMS_MNY_IN_OUT_MGT WITH(NOLOCK)
        WHERE Class = 'AA003'
          AND Account IN (
                SELECT Cd
                  FROM UPDMS_COM_CD WITH(NOLOCK)
                 WHERE Id = 'MNY'
                   AND Cd LIKE 'AD%'
                   AND Attr1 = 'Y'
              )
        GROUP BY Account
       ) x
 ORDER BY Account

GO